import { getPermissionByParentId } from '@/view/api/permissionManager.js'
import { yfuPost } from '@/utils/request.js'
import { returnUrlString } from '@/utils/PermissionUtils.js'

export default function getPermissionByMenuId (userId, menuId, func) {
  let params = {}
  params.userId = userId
  params.parentId = menuId

  yfuPost(process.env.BASE_API, getPermissionByParentId.url, params,
    function (data) {
      console.log(data)
      let permissionString = returnUrlString(data)
      if (permissionString === undefined) {
        permissionString = ''
      }
      func(permissionString)
    },
    function (error) {
      console.log(error)
    }
  )
}
